﻿using System.Windows.Browser;

namespace HtmlUtilities
{
    public interface IHtmlEventArgs
    {
        bool AltKey { get; }
        int CharacterCode { get; }
        int ClientX { get; }
        int ClientY { get; }
        bool CtrlKey { get; }
        IScriptObject EventObject { get; }
        string EventType { get; }
        int KeyCode { get; }
        MouseButtons MouseButton { get; }
        int OffsetX { get; }
        int OffsetY { get; }
        void PreventDefault();
        int ScreenX { get; }
        int ScreenY { get; }
        bool ShiftKey { get; }
        IHtmlObject Source { get; }
        void StopPropagation();
    }

    internal class HtmlEventArgsWrapper : IHtmlEventArgs
    {
        private readonly HtmlEventArgs _args;
        public HtmlEventArgsWrapper(HtmlEventArgs args)
        {
            _args = args;
        }

        public bool AltKey
        {
            get { return _args.AltKey; }
        }

        public int CharacterCode
        {
            get { return _args.CharacterCode; }
        }

        public int ClientX
        {
            get { return _args.ClientX; }
        }

        public int ClientY
        {
            get { return _args.ClientY; }
        }

        public bool CtrlKey
        {
            get { return _args.CtrlKey; }
        }

        public IScriptObject EventObject
        {
            get { return ScriptObjectFactory.GetScriptObject(_args.Source); }
        }

        public string EventType
        {
            get { return _args.EventType; }
        }

        public int KeyCode
        {
            get { return _args.KeyCode; }
        }

        public MouseButtons MouseButton
        {
            get { return _args.MouseButton; }
        }

        public int OffsetX
        {
            get { return _args.OffsetX; }
        }

        public int OffsetY
        {
            get { return _args.OffsetY; }
        }

        public void PreventDefault()
        {
            _args.PreventDefault();
        }

        public int ScreenX
        {
            get { return _args.ScreenX; }
        }

        public int ScreenY
        {
            get { return _args.ScreenY; }
        }

        public bool ShiftKey
        {
            get { return _args.ShiftKey; }
        }

        public IHtmlObject Source
        {
            get { return ScriptObjectFactory.GetScriptObject(_args.Source) as HtmlObjectWrapper; }
        }

        public void StopPropagation()
        {
            _args.StopPropagation();
        }
    }
}
